<?php
    if(isset($_GET["id"])){
        $id = $_GET["id"];
    }

    if (!empty($_POST["clave"])) {
        require_once('includes/bbb-api.php');
        $bbb = new BigBlueButton();

        $datos = array(
            'meetingId'    => $_POST["id"], // REQUIRED - We have to know which meeting to join.
            'username'     => $_POST["nombre"], // REQUIRED - The user display name that will show in the BBB meeting.
            'password'     => $_POST["clave"], // REQUIRED - Must match either attendee or moderator pass for meeting.
            'createTime'   => '', // OPTIONAL - string
            'userId'       => '', // OPTIONAL - string
            'webVoiceConf' => '' // OPTIONAL - string
        );
        try {
            $resultado = $bbb->getJoinMeetingURL($datos);
			
        } catch (Exception $e) {
            die('ERROR: ' . $e->getMessage());
        }
        header("location: " . $resultado);

    }


?>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <title>ESAN Test</title>
    <style>
        body {
            font-family: Verdana
        }
    </style>
</head>
<body>
<form id="moderador" method="post" action="ingresar.php">
    <label>Nombre:</label>
    <input type="text" name="nombre"/>
    <label>Clave:</label>
    <input type="text" name="clave"/>
    <input type="hidden" name="id" value="<?php echo $id ?>"/>
    <input type="submit" value="enviar"/>
</form>
</body>
</html>